<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		
	<span class="different-posts different-posts_earlier">📖 <a href="/page/59">earlier posts</a> 📖</span>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/42.Linux系统和用户的环境变量配置文件/">Linux系统和用户的环境变量配置文件</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;linux系统中，有很多系统的变量，这些变量被存在</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>/etc/profile</strong>: 这个文件预设了几个重要的变量，例如 PATH , USER , LOGNAME , MAIL , INPUTRC , HOSTNAME , HISTSIZE , umake等等。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>/etc/bashrc</strong>: 这个文件主要预设umake以及PS1。这个PS1就是我们在敲命令的时，前面那串字符了，例如CentOS root用户默认PS1就是[root@localhost~]#，PS1的值。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/u 就是用户，/h 主机名，/W 则是当前目录，/$ 就是那个‘#’了。如果普通用户显示为‘$’。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;除了两个系统级别的配置文件外，每个用户的主目录下还有几个这样的隐藏文件：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>.bash_proffile</strong>: 定义了用户的个人划路径与环境变量的文件名称。每个用户都可使用该文件输入专用于自己使用的shell信息，当用户登录时，该文件仅仅执行一次。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>.bash_history</strong>: 记录命令历史用的。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>.bash_logout</strong>: 当退出shell时，会执行该文件。可以把一些清理的工作放到这个文件中。</p>

	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/41.Linux环境变量之“PS1”/">Linux环境变量之“PS1”</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;PS1（是数字1而不是字母l），每个版本bash的PS1变量内的特殊符号可能有些小的差异，你可以先man bash 一下。下面是FC4环境下默认的特殊符号所代表的意义：</p>
<ul>
<li><p>\d ：代表日期，格式为weekday month date，例如：”Mon Aug 1”</p>
</li>
<li><p>\H ：完整的主机名称。例如：我的机器名称为：fc4.linux，则这个名称就是fc4.linux</p>
</li>
<li><p>\h ：仅取主机的第一个名字，如上例，则为fc4，.linux则被省略</p>
</li>
<li><p>\t ：显示时间为24小时格式，如：HH：MM：SS</p>
</li>
<li><p>\T ：显示时间为12小时格式</p>
</li>
<li><p>\A ：显示时间为24小时格式：HH：MM</p>
</li>
<li><p>\u ：当前用户的账号名称</p>
</li>
<li><p>\v ：BASH的版本信息</p>
</li>
<li><p>\w ：完整的工作目录名称。家目录会以 ~代替</p>
</li>
<li><p>\W ：利用basename取得工作目录名称，所以只会列出最后一个目录</p>
</li>
<li><p>\# ：下达的第几个命令</p>
</li>
<li><p>\$ ：提示字符，如果是root时，提示符为：#   ，普通用户则为：$</p>
</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;默认的PS1内容为： ‘[\u@\h \W]\$ ‘ ，所以默认的提示符就是： </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># 。</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;但设置PS1的时候需要稍微处理一下</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">PS1=<span class="string">"[\\u@\\h \\W]\\$ "</span>  这样显示的结果才是正确的</div></pre></td></tr></table></figure>
	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/40.Linux源码包安装/">Linux源码包安装</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在linux下面安装一个源码包是最常用的，在日常的管理工作中，大部分软件都是通过源码安装的。安装一个源码包，是需要自己把源代码编译成二进制的可执行文件。如果读得懂这些源代码，那么就可以去修改这些源代码自定义功能，然后再去编译成想要的。使用源码包的好处除了可以自定义修改源代码外还可以定制相关的功能，因为源码包在编译的时候是可以附加额外的选项的。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;源码包的编译用到了linux系统里的编译器，常见的源码包一般都是用C语言开发的，这也是因为C语言为linux上最标准的程序语言。Linux上的C语言编译器叫做gcc，利用它就可以把C语言变成可执行的二进制文件。所以如果你的机器上没有安装gcc就没有办法去编译源码。你可以使用 yum install -y gcc 来完成安装。</p>
<h2 id="安装一个源码包，通常需要三个步骤："><a href="#安装一个源码包，通常需要三个步骤：" class="headerlink" title="安装一个源码包，通常需要三个步骤："></a>安装一个源码包，通常需要三个步骤：</h2><h3 id="configure"><a href="#configure" class="headerlink" title="./configure"></a>./configure</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在这一步可以定制功能，加上相应的选项即可，具有有什么选项可以通过 ./configure –help 命令来查看。在这一步会自动检测你的linux系统与相关的套件是否有编译该源码包时需要的库，因为一旦缺少某个库就不能完成编译。只有检测通过后才会生成一个Makefile文件。</p>
<h3 id="make"><a href="#make" class="headerlink" title="make"></a>make</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;使用这个命令会根据Makefile文件中预设的参数进行编译，这一步其实就是gcc在工作了。</p>
<h3 id="make-install"><a href="#make-install" class="headerlink" title="make install"></a>make install</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;安装步骤，生成相关的软件存放目录和配置文件的过程。</p>
<h2 id="Apache源码安装实例"><a href="#Apache源码安装实例" class="headerlink" title="Apache源码安装实例"></a>Apache源码安装实例</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;上面的3步并不是所有的源码包软件都一样的，也就是说源码包的安装并非具有一定的标准安装步骤。这就需要拿到源码包解压后，然后进入到目录找相关的帮助文档，通常会以INSTALL或者README为文件名。所以一定要去看一下。</p>
<h3 id="1-下载一个源码包"><a href="#1-下载一个源码包" class="headerlink" title="1.下载一个源码包"></a>1.下载一个源码包</h3><p>下载源码包一定要去官方站点去下载，不要在网上随便下载，那样很不安全。因为下载到的源码包很有可能是被人修改过的。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost src]<span class="comment"># cd /usr/local/src/</span></div><div class="line">[root@localhost src]<span class="comment"># wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.27.tar.bz2</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下载地址为apache官方网站上提供的一个镜像，下载速度还可以。在下载之前，进入到了 “/usr/local/src” 目录，这是因为习惯把源码包都放到这个目录下，这样做的好处是，方便自己和其他管理员维护，所以以后下载的源码包都统一放到这个目录下吧。</p>
<h3 id="2-解压源码包"><a href="#2-解压源码包" class="headerlink" title="2.解压源码包"></a>2.解压源码包</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost src]<span class="comment"># tar jxvf httpd-2.2.27.tar.bz2</span></div></pre></td></tr></table></figure>
<h3 id="3-配置相关的选项，并生成Makefile"><a href="#3-配置相关的选项，并生成Makefile" class="headerlink" title="3.配置相关的选项，并生成Makefile"></a>3.配置相关的选项，并生成Makefile</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">[root@localhost src]<span class="comment"># cd httpd-2.2.27</span></div><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># ./configure --help |less</span></div><div class="line">`configure<span class="string">' configures this package to adapt to many kinds of systems.</span></div><div class="line"><span class="string"></span></div><div class="line"><span class="string">Usage: ./configure [OPTION]... [VAR=VALUE]...</span></div><div class="line"><span class="string"></span></div><div class="line"><span class="string">To assign environment variables (e.g., CC, CFLAGS...), specify them as</span></div><div class="line"><span class="string">VAR=VALUE.  See below for descriptions of some of the useful variables.</span></div><div class="line"><span class="string"></span></div><div class="line"><span class="string">Defaults for the options are specified in brackets.</span></div><div class="line"><span class="string"></span></div><div class="line"><span class="string">Configuration:</span></div><div class="line"><span class="string">  -h, --help              display this help and exit</span></div><div class="line"><span class="string">      --help=short        display options specific to this package</span></div><div class="line"><span class="string">      --help=recursive    display the short help of all the included packages</span></div><div class="line"><span class="string">  -V, --version           display version information and exit</span></div><div class="line"><span class="string">  -q, --quiet, --silent   do not print `checking ...'</span> messages</div><div class="line">      --cache-file=FILE   cache <span class="built_in">test</span> results <span class="keyword">in</span> FILE [disabled]</div><div class="line">  -C, --config-cache      <span class="built_in">alias</span> <span class="keyword">for</span> `--cache-file=config.cache<span class="string">'</span></div><div class="line"><span class="string">  -n, --no-create         do not create output files</span></div><div class="line"><span class="string">      --srcdir=DIR        find the sources in DIR [configure dir or `..'</span>]</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;使用 ./configure –help 命令查看可以使用的选项。一般常用的有 –prefix=PREFIX 这个选项的意思是定义软件包安装到哪里。一个小小的建议，通常源码包都是安装在/usr/local/目录下的。比如，把apache安装在/usr/local/apache2下，那么这里就应该这样写 –prefix=/usr/local/apache2 其他还有好多选项，如果有耐心可以挨个去看一看都有什么作用。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># ./configure --prefix=/usr/local/apache2</span></div><div class="line">checking <span class="keyword">for</span> chosen layout... Apache</div><div class="line">checking <span class="keyword">for</span> working mkdir -p... yes</div><div class="line">checking build system <span class="built_in">type</span>... i686-pc-linux-gnu</div><div class="line">checking host system <span class="built_in">type</span>... i686-pc-linux-gnu</div><div class="line">checking target system <span class="built_in">type</span>... i686-pc-linux-gnu</div><div class="line"></div><div class="line">Configuring Apache Portable Runtime library ...</div><div class="line"></div><div class="line">checking <span class="keyword">for</span> APR... reconfig</div><div class="line">configuring package <span class="keyword">in</span> srclib/apr now</div><div class="line">checking build system <span class="built_in">type</span>... i686-pc-linux-gnu</div><div class="line">checking host system <span class="built_in">type</span>... i686-pc-linux-gnu</div><div class="line">checking target system <span class="built_in">type</span>... i686-pc-linux-gnu</div><div class="line">Configuring APR library</div><div class="line">Platform: i686-pc-linux-gnu</div><div class="line">checking <span class="keyword">for</span> working mkdir -p... yes</div><div class="line">APR Version: 1.4.6</div><div class="line">checking <span class="keyword">for</span> chosen layout... apr</div><div class="line">checking <span class="keyword">for</span> gcc... no</div><div class="line">checking <span class="keyword">for</span> cc... no</div><div class="line">checking <span class="keyword">for</span> cl.exe... no</div><div class="line">configure: error: <span class="keyword">in</span> `/usr/<span class="built_in">local</span>/src/httpd-2.2.27/srclib/apr<span class="string">':</span></div><div class="line"><span class="string">configure: error: no acceptable C compiler found in $PATH</span></div><div class="line"><span class="string">See `config.log'</span> <span class="keyword">for</span> more details</div><div class="line">configure failed <span class="keyword">for</span> srclib/apr</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;不幸的是，一开始就报错了，因为没有gcc编译器，需要先安装一下。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># yum install -y gcc</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;由于gcc依赖的包很多，所以安装时间会长一些。安装完后，再继续上面的步骤。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># ./configure --prefix=/usr/local/apache2</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;验证这一步是否成功的命令是：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># echo $?</span></div><div class="line">0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;返回值如果是 “0” 则执行成功，否则就是没有成功。此时就成功生成 Makefile 了。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># ls -l Makefile</span></div><div class="line">-rw-r--r-- 1 root root 8954 5月  13 12:02 Makefile</div></pre></td></tr></table></figure>
<h3 id="4-进行编译"><a href="#4-进行编译" class="headerlink" title="4.进行编译"></a>4.进行编译</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># make</span></div><div class="line">-bash: make: <span class="built_in">command</span> not found</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;又发生错误了，提示 “make” 命令没有发现，解决办法是安装make工具。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># yum install -y make</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;继续make</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># make</span></div><div class="line">Making all <span class="keyword">in</span> srclib</div><div class="line">make[1]: Entering directory `/usr/<span class="built_in">local</span>/src/httpd-2.2.27/srclib<span class="string">'</span></div><div class="line"><span class="string">Making all in apr</span></div><div class="line"><span class="string">make[2]: Entering directory `/usr/local/src/httpd-2.2.27/srclib/apr'</span></div><div class="line">make[3]: Entering directory `/usr/<span class="built_in">local</span>/src/httpd-2.2.27/srclib/apr<span class="string">'</span></div><div class="line"><span class="string">/bin/sh /usr/local/src/httpd-2.2.27/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE   -I./include -I/usr/local/src/httpd-2.2.27/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.27/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.27/srclib/apr/include  -o passwd/apr_getpass.lo -c passwd/apr_getpass.c &amp;&amp; touch passwd/apr_getpass.lo</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;编译的时候，就会出现类似这么多乱七八糟的信息，编译的时间比较长，CPU使用率会很高，这是因为CPU高速计算，编译完后，再使用 echo $? 验证一下是否正常成功。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># echo $?</span></div><div class="line">0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果是0的话，就可以执行最后一步了。</p>
<h3 id="5-安装"><a href="#5-安装" class="headerlink" title="5.安装"></a>5.安装</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># make install</span></div><div class="line">Making install <span class="keyword">in</span> srclib</div><div class="line">make[1]: Entering directory `/usr/<span class="built_in">local</span>/src/httpd-2.2.27/srclib<span class="string">'</span></div><div class="line"><span class="string">Making install in apr</span></div><div class="line"><span class="string">make[2]: Entering directory `/usr/local/src/httpd-2.2.27/srclib/apr'</span></div><div class="line">make[3]: Entering directory `/usr/<span class="built_in">local</span>/src/httpd-2.2.27/srclib/apr<span class="string">'</span></div><div class="line"><span class="string">make[3]: Nothing to be done for `local-all'</span>.</div><div class="line">make[3]: Leaving directory `/usr/<span class="built_in">local</span>/src/httpd-2.2.27/srclib/apr<span class="string">'</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;当然也可以使用 echo $? 看看有没有正确安装，执行完这一步，则会在 “/usr/local/apache2” 目录下增加了很多目录。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@localhost httpd-2.2.27]<span class="comment"># ls /usr/local/apache2/</span></div><div class="line">bin    cgi-bin  error   icons    lib   man     modules</div><div class="line">build  conf     htdocs  include  logs  manual</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;到此，apache源码的安装就完成了</p>

	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/4. Linux 环境变量/">Linux 环境变量</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<h2 id="显示环境变量"><a href="#显示环境变量" class="headerlink" title="显示环境变量"></a>显示环境变量</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">echo</span> $[变量名]</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>示例：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">echo</span> <span class="variable">$HOME</span></div><div class="line">/root</div></pre></td></tr></table></figure>
<h2 id="设置一个新的环境变量"><a href="#设置一个新的环境变量" class="headerlink" title="设置一个新的环境变量"></a>设置一个新的环境变量</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">export</span> HELLO=<span class="string">"Hello!"</span></div><div class="line">$ <span class="built_in">echo</span> <span class="variable">$HELLO</span></div><div class="line">Hello!</div></pre></td></tr></table></figure>
<h3 id="查看全局环境变量命令：env"><a href="#查看全局环境变量命令：env" class="headerlink" title="查看全局环境变量命令：env"></a>查看全局环境变量命令：env</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>使用 <code>env</code> 命令显示所有的环境变量</strong>   </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">$ env</div><div class="line">HOSTNAME=redbooks.safe.org</div><div class="line">PVM_RSH=/usr/bin/rsh</div><div class="line">Shell=/bin/bash</div><div class="line">TERM=xterm</div><div class="line">HISTSIZE=1000</div></pre></td></tr></table></figure>
<h2 id="查看所有环境变量命令：set"><a href="#查看所有环境变量命令：set" class="headerlink" title="查看所有环境变量命令：set"></a>查看所有环境变量命令：set</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>使用 <code>set</code> 命令显示所有本地定义的 shell 变量</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">set</span></div><div class="line">BASH=/bin/bash</div><div class="line">BASH_VERSINFO=([0]=<span class="string">"2"</span>[1]=<span class="string">"05b"</span>[2]=<span class="string">"0"</span>[3]=<span class="string">"1"</span>[4]=<span class="string">"release"</span>[5]=<span class="string">"i386-redhat-linux-gnu"</span>)</div><div class="line">BASH_VERSION=<span class="string">'2.05b.0(1)-release'</span></div><div class="line">COLORS=/etc/DIR_COLORS.xterm</div><div class="line">COLUMNS=80</div><div class="line">DIRSTACK=()</div><div class="line">DISPLAY=:0.0</div></pre></td></tr></table></figure>
<h2 id="删除一个变量：unset"><a href="#删除一个变量：unset" class="headerlink" title="删除一个变量：unset"></a>删除一个变量：unset</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong>  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">unset</span> [变量名]</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;只针对当前会话</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set可以设置某个环境变量的值。清除环境变量的值用unset命令。如果未指定值，则该变量值将被设为NULL。示例如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">export</span> TEST=<span class="string">"Test..."</span> <span class="comment">#增加一个环境变量TEST</span></div><div class="line">$ env|grep TEST <span class="comment">#此命令有输入，证明环境变量TEST已经存在了</span></div><div class="line">TEST=Test...</div><div class="line">$ <span class="built_in">unset</span> <span class="variable">$TEST</span> <span class="comment">#删除环境变量TEST</span></div><div class="line">$ env|grep TEST <span class="comment">#此命令没有输出，证明环境变量TEST已经存在了</span></div></pre></td></tr></table></figure>
<h2 id="使用-readonly-命令设置只读变量"><a href="#使用-readonly-命令设置只读变量" class="headerlink" title="使用 readonly 命令设置只读变量"></a>使用 readonly 命令设置只读变量</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果使用了 readonly 命令，变量就不可以被修改或清除了<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;示例如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">export</span> TEST=<span class="string">"Test..."</span> <span class="comment">#增加一个环境变量TEST</span></div><div class="line">$ <span class="built_in">readonly</span> TEST <span class="comment">#将环境变量TEST设为只读</span></div><div class="line">$ <span class="built_in">unset</span> TEST <span class="comment">#会发现此变量不能被删除</span></div><div class="line">-bash: <span class="built_in">unset</span>: TEST: cannot <span class="built_in">unset</span>: <span class="built_in">readonly</span> variable</div><div class="line">$ TEST=<span class="string">"New"</span> <span class="comment">#会发现此也变量不能被修改</span></div><div class="line">-bash: TEST: <span class="built_in">readonly</span> variable</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;环境变量的设置位于 <code>/etc/profile</code> 文件，如果需要增加新的环境变量可以添加下属行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">export</span> PATH=<span class="variable">$PATH</span>:/PATH1:/PATH2:/PATHN</div></pre></td></tr></table></figure>
<h2 id="Linux-的变量种类"><a href="#Linux-的变量种类" class="headerlink" title="Linux 的变量种类"></a>Linux 的变量种类</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;按变量的生存周期来划分，Linux 变量可范围两类：<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;1、永久的：需要修改配置文件，变量永久生效。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;2、临时的：使用 export 命令声明即可，变量在关闭 shell 时失效。</p>
<h2 id="环境变量的配置文件"><a href="#环境变量的配置文件" class="headerlink" title="环境变量的配置文件"></a>环境变量的配置文件</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;全局： <code>/etc/profile</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;局部： <code>~/.bash_profile</code></p>
<h2 id="设置变量的方法"><a href="#设置变量的方法" class="headerlink" title="设置变量的方法"></a>设置变量的方法</h2><h3 id="1-在-etc-profile-文件中添加变量｛对所有用户生效（永久的）｝"><a href="#1-在-etc-profile-文件中添加变量｛对所有用户生效（永久的）｝" class="headerlink" title="1.在 /etc/profile 文件中添加变量｛对所有用户生效（永久的）｝"></a>1.在 /etc/profile 文件中添加变量｛对所有用户生效（永久的）｝</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;用 <code>vim</code> 在文件 <code>/etc/profile</code> 文件中增加变量，该变量将会对 Linux下 所有用户有效，并且是“永久的”。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;例如：编辑 /etc/profile 文件，添加CLASSPATH变量   </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># vim /etc/profile</span></div><div class="line"><span class="built_in">export</span> CLASSPATH=./JAVA_HOME/lib;<span class="variable">$JAVA_HOME</span>/jre/lib</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;注：修改文件后要想马上生效还要运行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># source /etc/profile</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;不然只能在下次重进此用户时生效</p>
<h3 id="2-在用户目录下个-bash-profile-文件中增加变量｛对单一用户生效（永久的）｝"><a href="#2-在用户目录下个-bash-profile-文件中增加变量｛对单一用户生效（永久的）｝" class="headerlink" title="2.在用户目录下个 .bash_profile 文件中增加变量｛对单一用户生效（永久的）｝"></a>2.在用户目录下个 <code>.bash_profile</code> 文件中增加变量｛对单一用户生效（永久的）｝</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;用 <code>vim</code>在用户目录下的 <code>.bash_profile</code> 文件中增加变量，改变量仅会对当前用户有效，并且是“永久的”。<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;例如：编辑guok用户目录(/home/guok)下的.bash_profile   </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ vim /home/guok/.bash.profile</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;添加如下内容</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">export</span> CLASSPATH=./JAVA_HOME/lib;<span class="variable">$JAVA_HOME</span>/jre/lib</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;注：修改文件后要想马上生效还要运行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">source</span> /home/guok/.bash_profile</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;不然只能在下次重进此用户时生效</p>
<h3 id="3-直接运行-export-命令定义变量｛只对当前-shell-（BASH）有效（临时的）｝"><a href="#3-直接运行-export-命令定义变量｛只对当前-shell-（BASH）有效（临时的）｝" class="headerlink" title="3.直接运行 export 命令定义变量｛只对当前 shell （BASH）有效（临时的）｝"></a>3.直接运行 export 命令定义变量｛只对当前 shell （BASH）有效（临时的）｝</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">export</span> JAVA_HOME=/usr/<span class="built_in">local</span>/java   <span class="comment">#添加新变量名</span></div><div class="line"><span class="built_in">export</span> PATH=<span class="variable">$PATH</span>:/usr/<span class="built_in">local</span>/php/bin <span class="comment">#修改已有变量名</span></div></pre></td></tr></table></figure>
<h2 id="常用的环境变量"><a href="#常用的环境变量" class="headerlink" title="常用的环境变量"></a>常用的环境变量</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;PATH：决定了shell将到哪些目录中寻找命令或程序，PATH的值是一系列以冒号分割的目录<br>注意：最好不要把 “./“ 放到 PATH 中，这样会引起安全问题</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;HOME：当前用户主目录</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;HISTSIZE：历史记录数</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;LOGNAME：当前用户的登录名</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;HOSTNAME：指主机的名称</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SHELL：当前用户Shell类型</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;LANGUGE：语言相关的环境变量，多语言可以修改此环境变量</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;MAIL&#160;&#160;&#160;&#160;当前用户的邮件存放目录</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;PS1：[\u@\h \W]\$ &#160;&#160;&#160;&#160;基本提示符，对于root用户是#，对于普通用户是$</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;PS2:敲错以后进入的符号</p>
<h4 id="PATH-声明，其格式为"><a href="#PATH-声明，其格式为" class="headerlink" title="PATH 声明，其格式为"></a>PATH 声明，其格式为</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">PATH=<span class="variable">$PATH</span>:&lt;PATH 1&gt;:&lt;PATH 2&gt;:&lt;PATH 3&gt;:------:&lt;PATH N&gt;</div></pre></td></tr></table></figure>

	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/39.yum局域网软件源搭建/">yum局域网软件源搭建</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<h2 id="1-搭建apache服务器或ftp服务器"><a href="#1-搭建apache服务器或ftp服务器" class="headerlink" title="1.搭建apache服务器或ftp服务器"></a>1.搭建apache服务器或ftp服务器</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;yum安装或二进制安装</p>
<h2 id="2、准备RPM包"><a href="#2、准备RPM包" class="headerlink" title="2、准备RPM包"></a>2、准备RPM包</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;把CentOS的DVD1和DVD2.iso都下载下来，把DVD1.iso里的所有内容解压出来，放到/var/www/html/centos-6目录下，然后把DVD2.iso解压出来的Packages目录下的rpm包复制到/var/html/centos-6/Packages目录下，这样/var/html/centos-6/Packages里面就有了6000多个rpm包。</p>
<h2 id="3、创建yum仓库"><a href="#3、创建yum仓库" class="headerlink" title="3、创建yum仓库"></a>3、创建yum仓库</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;准备createrepo：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum -y install createrepo</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;创建repository：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">createrepo /var/www/html/centos-6/</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;创建完成之后，会在/var/www/html/centos-6/repodata下生成一些文件。</p>
<h2 id="4、使用软件源"><a href="#4、使用软件源" class="headerlink" title="4、使用软件源"></a>4、使用软件源</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在其他centos机器上试试软件源能不能用。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;首先修改机器上软件源配置文件：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># cd /etc/yum.repos.d/</span></div><div class="line"><span class="comment"># mkdir bk</span></div><div class="line"><span class="comment"># mv *.repo bk/</span></div><div class="line"><span class="comment"># cp bk/CentOS-Base.repo ./</span></div><div class="line"><span class="comment"># vi CentOS-Base.repo</span></div><div class="line">CentOS-Base.repo文件修改之后如下：</div><div class="line">[base]</div><div class="line">name=CentOS-<span class="variable">$releasever</span> - Base</div><div class="line">baseurl=http://*.*.*.*/centos-6/</div><div class="line">gpgcheck=1(改成0下面那行就不用设置了)</div><div class="line">gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6</div><div class="line">enabled=1</div><div class="line"><span class="comment">#released updates</span></div><div class="line"><span class="comment">#[updates]</span></div><div class="line"><span class="comment">#name=CentOS-$releasever - Updates</span></div><div class="line"><span class="comment">#baseurl=http:///*.*.*.*/centos-6/</span></div><div class="line"><span class="comment">#gpgcheck=1</span></div><div class="line"><span class="comment">#gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6</span></div><div class="line"><span class="comment">#enabled = 1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存之后，就可以使用局域网的软件源了：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># yum update</span></div></pre></td></tr></table></figure>
	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/38.yum更新源优先级设置/">yum更新源优先级设置</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<h2 id="1-安装-yum-priorities"><a href="#1-安装-yum-priorities" class="headerlink" title="1.安装 yum-priorities"></a>1.安装 yum-priorities</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum install yum-priorities</div></pre></td></tr></table></figure>
<h2 id="2-priorities的配置文件是-etc-yum-pluginconf-d-priorities-conf，确认其是否存在。"><a href="#2-priorities的配置文件是-etc-yum-pluginconf-d-priorities-conf，确认其是否存在。" class="headerlink" title="2.priorities的配置文件是/etc/yum/pluginconf.d/priorities.conf，确认其是否存在。"></a>2.priorities的配置文件是/etc/yum/pluginconf.d/priorities.conf，确认其是否存在。</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;其内容为:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[main]</div><div class="line">enabled=1   <span class="comment"># 0禁用 1启用</span></div></pre></td></tr></table></figure>
<h2 id="3-编辑-etc-yum-repos-d-目录下的-repo-文件来设置优先级。"><a href="#3-编辑-etc-yum-repos-d-目录下的-repo-文件来设置优先级。" class="headerlink" title="3.编辑 /etc/yum.repos.d/目录下的*.repo 文件来设置优先级。"></a>3.编辑 /etc/yum.repos.d/目录下的*.repo 文件来设置优先级。</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;参数为：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">priority=N   <span class="comment"># N的值为1-99</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;推荐的设置为：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[base], [addons], [updates], [extras] … priority=1</div><div class="line">[centosplus],[contrib] … priority=2</div><div class="line">Third Party Repos such as rpmforge … priority=N   (<span class="built_in">where</span> N is &gt; 10 and based on your preference)</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;数字越大,优先级越低</p>

	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/37. 利用tar通过网络拷贝数据/">利用tar通过网络拷贝数据</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># cd /data  // data目录下有我们要拷贝的目标文件目录 test</span></div><div class="line"><span class="comment"># tar cvf  -  test| ssh 10.0.1.11 "cd /copy1/; tar xvf  -"  //首先将要拷贝的目录test打包，"-" 代表标准输出，然后再ssh 到目标主机 10.0.1.11 ，运行相应的命令。其中tar xvf  - 意思是，将前面的标准输出内容作为解包的对象。</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;总结：其实就是想拷贝的目录先打包，然后将打包好的文件拷贝到目标主机，最后在目标主机上解包。只不过，我们用一条命令实现了边打包边解包的过程。</p>

	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/35. vim粘贴代码自动缩进导致全乱了/">vim粘贴代码自动缩进导致全乱了</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;用vim打开一个空白文档，然后把已经复制的代码给粘贴进来，发现它有自动缩进功能，最终导致粘贴的文本一行比一行靠右，看起来乱成一团。比较快的解决办法是，在粘贴文档前，在命令行模式下，输入</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">:<span class="built_in">set</span> noai nosi</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后按’i’ 进入编辑模式，再粘贴已经复制的代码内容，这样就不会自动缩进了。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;有时候，这样的方法不好用，可以尝试这种：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">:<span class="built_in">set</span> paste</div></pre></td></tr></table></figure>
	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/36. Linux解压大于4G的压缩包/">Linux解压大于4G的压缩包</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Linux下不支持解压大于4G的zip压缩包。解决办法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">wget -c http://packages.sw.be/p7zip/p7zip-9.13-1.el5.rf.i386.rpm</div><div class="line">wget -c http://packages.sw.be/p7zip/p7zip-plugins-9.13-1.el5.rf.i386.rpm</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下载完成后安装：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">rpm -ivh p7zip-9.13-1.el5.rf.i386.rpm</div><div class="line">rpm -ivh p7zip-plugins-9.13-1.el5.rf.i386.rpm</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;解压命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">7z x 123.zip</div></pre></td></tr></table></figure>

	

	

</article>




	<article>
	
		<h1><a href="/2017/10/12/1. Linux 基础/34. vim快速删除制定的一段字符/">vim快速删除制定的一段字符</a></h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;因为不是一行，所以用<code>dd</code>不行，但用<code>x</code>去删除的话，又太慢。今天发现一种特别快速删除的方法。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;那就是使用<code>da</code>，如何使用，请看下面的例子。<br>比如，我的1.txt内容如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">11111111111111111111111111</div><div class="line">222222222222222222222222222222B3NzaC1yc2EAAAABIwAAAQEAv5oJvuIdaaVUsDOA2FbfnL0K2GbTc05Yg6TGM+8SNleI6bU5MhAy2uP5J4yCrMu43911hEJ2uh1UPycWX1O4xpEgUm8TGIs1HoQySnukv3g121uOLACRj37qqL9j4RRhrUxhunAW3alLSGIV0mxFD0ApyycFoLA/1I3hU7Yyx7tdripwz0FeHHhT3Qjfe9yC8Z6Ptq7cvBPXBBvc/G8pXVq3bnGMtj9Ifmbh7NnTvfHnEZGacf2MR4FSy0MMuNL0k3X5sBlsyP9/rXY9CPOh73eKUhZQoK3uWjwuDRp/dqrxgWDVeg0NZ+0t130pKu/LSREothWoVBu54rrtUUIdb3Sq0xsW4x9EhKGJJHPvBrbGbiDPTKBUaHdQEfmQQPAWeeX1hMC7lCunnfgTzf39Pv/2VpXz2l8NH2Jem0nrS48A6sf4eFz5VIakoRySMQu/6mY4s9aU3arbX+JvUE9s2/7D+JdqJlINtQqRU4V92LQq3BJaSMmKiwnPSytxDtARI3+8I2XXqFCJ5bBY7e3333333333333333333333</div><div class="line">44444444444444444444444444444</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;我现在想删除22222222222和33333333333333333之间的字符只需要这样做：</p>
<ol>
<li>把1.txt的内容改成：</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">11111111111111111111111111</div><div class="line">222222222222222222222222222222&#123;B3NzaC1yc2EAAAABIwAAAQEAv5oJvuIdaaVUsDOA2FbfnL0K2GbTc05Yg6TGM+8SNleI6bU5MhAy2uP5J4yCrMu43911hEJ2uh1UPycWX1O4xpEgUm8TGIs1HoQySnukv3g121uOLACRj37qqL9j4RRhrUxhunAW3alLSGIV0mxFD0ApyycFoLA/1I3hU7Yyx7tdripwz0FeHHhT3Qjfe9yC8Z6Ptq7cvBPXBBvc/G8pXVq3bnGMtj9Ifmbh7NnTvfHnEZGacf2MR4FSy0MMuNL0k3X5sBlsyP9/rXY9CPOh73eKUhZQoK3uWjwuDRp/dqrxgWDVeg0NZ+0t130pKu/LSREothWoVBu54rrtUUIdb3Sq0xsW4x9EhKGJJHPvBrbGbiDPTKBUaHdQEfmQQPAWeeX1hMC7lCunnfgTzf39Pv/2VpXz2l8NH2Jem0nrS48A6sf4eFz5VIakoRySMQu/6mY4s9aU3arbX+JvUE9s2/7D+JdqJlINtQqRU4V92LQq3BJaSMmKiwnPSytxDtARI3+8I2XXqFCJ5bBY7e&#125;3333333333333333333333</div><div class="line">44444444444444444444444444444</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;注意，2222 和{ 之间没有换行。</p>
<ol>
<li>把光标移动到第一个{，也就是最后一个2后，然后输入<code>da{</code> 即可把{}内的字符全部删除。</li>
</ol>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;另外，除了可以使用{ 外，还可以使用 “, ‘, (  等成对的特殊符号。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;其实vim还有一个比较常用的那就是<code>v</code>了，用<code>v</code>和<code>d</code>来删除也挺方便的：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;打开一个文本后，直接按<code>v</code>，然后移动光标可以选中文本，当选中完你想要的文本后，直接按<code>d</code>，就删除了</p>

	

	

</article>





	<span class="different-posts">📖 <a href="/page/61">more posts</a> 📖</span>



	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
